{extend name="public/layout" /}
{block name="head_css"}
    <link rel="stylesheet" href="/static/index/css/index.css">
    <script src="/static/index/js/hammer.min.js?v={$version}"></script>
    <script src="/static/index/js/jquery.hammer.js?v={$version}"></script>
{/block}


{block name="main"}
    <!-- 顶部 -->
    <div class="container sam-header">
        <div class="search-input-box">
            <input id="keyword" type="search" name="keyword" value="" placeholder="请输入您要搜索的内容" />
            <div onclick="search_list()" class="icon-btn"></div>
        </div>
        <a href="{:url('/index/engineering/add')}" class="publish-btn">
            <div class="left-icon"></div>
            <div class="words">免费发布信息</div>
        </a>
    </div>
    <!-- 顶部 END -->

    <!-- 滚动图 -->
    <div id="carousel" class="carousel slide" data-ride="carousel">
        <ol class="carousel-indicators">
            {foreach name="$ad_list" item="item" key='key'}
                <li data-target="#carousel" data-slide-to="{$key}" class=" {if condition="$key eq 0"}active{/if}"></li>
            {/foreach}
        </ol>
        <div class="carousel-inner">
            {foreach name="$ad_list" item="item" key='key'}
                <div class="carousel-item {if condition="$key eq 0"}active{/if}">
                    <a href="{$item.url}">
                        <img style="max-height: 300px" class="d-block w-100" src="{$item.img}" alt="">
                    </a>
                </div>
            {/foreach}
        </div>
    </div>
    <!-- 滚动图 END -->

    <!-- 栏目入口 -->
    <div class="container sam-white-bg column-box sam-padding-all">
        {foreach name="$nav_list" item="item" }
            <a href="{:url($item.module.'/index')}">
                <div class="citem">
                    <div class="icon" style="background-image:url('{$item.logo}')">
                    </div>
                    <div class="name">{$item.name}</div>
                </div>
            </a>
        {/foreach}
    </div>
    <!-- 栏目入口 END -->

    <!-- 声学安装 -->
    <div class="container sam-white-bg line-box sam-padding-all">
        <div class="title">
            <div class="name">声学安装（公司/个人）</div>
            <a class="more" href="{:url('install/index')}">全部&nbsp;&gt;</a>
        </div>
        <div class="scrolling">
            {foreach name="install" item="item"}
                <a class="litem" href="{:url('install/detail',array('id'=>$item.id))}" style="background-color:transparent;background-image: url('{$item.logo}')">
                    <div class="label">
                        <div class="name">{$item.contacts}</div>
                        <div class="score">评价&nbsp;{$item.comment_num}条</div>
                    </div>
                </a>
            {/foreach}
        </div>
    </div>
    <!-- 声学安装 END -->

    <!-- 声学设计 -->
    <div class="container sam-white-bg line-box sam-padding-all">
        <div class="title">
            <div class="name">声学设计（公司/个人）</div>
            <a class="more" href="{:url('design/index')}">全部&nbsp;&gt;</a>
        </div>
        <div class="scrolling">
            {foreach name="design" item="item"}
                <a href="{:url('design/detail',array('id'=>$item.id))}" class="litem" style="background-color:transparent;background-image: url('{$item.logo}')">
                    <div class="label">
                        <div class="name">{$item.contacts}</div>
                        <div class="score">评价&nbsp;{$item.comment_num}条</div>
                    </div>
                </a>
            {/foreach}
        </div>
    </div>
    <!-- 声学设计 END -->

    <!-- 隔音方案 -->

    <!-- 隔音方案 END -->

    <!-- 工程信息 -->
    <div class="container sam-white-bg sam-padding-all list-box">
        <div class="title">
            <div class="line-sides"></div>
            <div class="name">工程信息</div>
            <div class="line-sides"></div>
        </div>
        <div class="content">

        </div>
    </div>
    <!-- 工程信息 END -->

    <!-- 加载框 -->
    <div class="load-box">
        <div class="licon"></div>
        <div class="ltips">正在加载列表</div>
    </div>
    <!-- 加载框 END -->
{/block}

{block name="script"}
    <script>
        $('.carousel').carousel({
            interval: 2000
        });

        $('.carousel').hammer().on('swipeleft', function(){
            $(this).carousel('next');
        });

        $('.carousel').hammer().on('swiperight', function(){
            $(this).carousel('prev');
        });
        function search_list() {
            var keyword = $('#keyword').val();
            window.location.href = '{:url('engineering/search')}?keyword='+keyword;
        }
        var loadHeight = $('.load-box').height();
        var windowHeight = $(window).height();
        var scTop = 0;
        var ajaxLoading = false;
        var is_end = false;
        var page = 1;
        $(window).scroll(function(e) {
            if($(window).scrollTop() - scTop > 0&&($(window).scrollTop() + windowHeight >= $(document).height() - loadHeight)&&!ajaxLoading) {
                $.ajax({
                    url: '{:url("index/index/ajax_engineering")}?page='+page,
                    method: 'get',
                    dataType: 'json',
                    beforeSend: function() {
                        ajaxLoading = true;
                    },
                    success: function (res) {
                        page = res.data.page;
                        if(res.data.is_end == 1){
                            is_end = true;
                            $('.load-box').each(function(){
                                $(this).remove();
                            });
                        }
                        $('.list-box>.content').append(res.data.content);
                        ajaxLoading = false;
                    },
                    error: function (xhr,status,error) {
                        alert('网络错误');
                    },
                });
            }
            scTop = $(window).scrollTop();
        });
    </script>
{/block}